package pers.lx.crm.dao.market;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import pers.lx.crm.entiy.market.MarketDO;
import pers.lx.crm.entiy.market.MarketInfoDO;

import java.util.List;

/**
 * Created by lx on 2017/4/25.
 */
@Repository
public interface MarketInfoDao {

    @Insert("insert into customer_flow(business_flow_id,customer_business_id,value) values(#{businessFlowId},#{customerBusinessId},#{value})")
    public void insertMarketInfo(MarketInfoDO marketInfoDO) ;

    @Update("update customer_flow set value=#{value} where id=#{id}")
    public void updateMarketInfo(MarketInfoDO marketInfoDO) ;

    @Select("select flow.name as name,flow.description as description,customer_flow.id as id,customer_flow.value as value,business_flow_id,customer_business_id from customer_flow,business_flow,flow where customer_flow.business_flow_id=business_flow.id and business_flow.flow_id=flow.id and customer_flow.customer_business_id=#{customerBusinessId} order by flow_order ASC")
    public List<MarketInfoDO> selectMarketInfo(int customerBusinessId) ;

    @Delete("delete from customer_flow where customer_business_id=#{id}")
    public void deleteMarketInfo(MarketDO marketDO) ;
}
